// pages/my/my.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    motto: 'Hello World',
    userInfo: {},
    hasUserInfo: false,
    canIUse: wx.canIUse('button.open-type.getUserInfo'),
    jifen: [{ integral: "0", coupon: "1", balance: "2", commission:"3"}],
    yuyue:[{
      tu: "../images/gerenyuyue.png", wode: "我的预约", jiantou:"../images/gerenfanhuiyou.png"
    }, 
    {
      tu: "../images/gerenwomaidaode.png", wode: "我买到的", jiantou: "../images/gerenfanhuiyou.png"
      },
      {
        tu: "../images/gerenwomaichude.png", wode: "我卖出的", jiantou: "../images/gerenfanhuiyou.png"
      },
      {
        tu: "../images/gerenwozudaode.png", wode: "我租到的", jiantou: "../images/gerenfanhuiyou.png"
      },
      {
        tu: "../images/gerenwofabude.png", wode: "我发布的", jiantou: "../images/gerenfanhuiyou.png"
      },
      {
        tu: "../images/gerenwodexiaoxi.png", wode: "我的消息", jiantou: "../images/gerenfanhuiyou.png"
      },
      {
        tu: "../images/gerenwodezuji.png", wode: "我的足迹", jiantou: "../images/gerenfanhuiyou.png"
      },
      ],
      tuandui:[
        {
          tu: "../images/gerenwodetuandui.png", wode: "我的团队", jiantou: "../images/gerenfanhuiyou.png"
        },
        {
          tu: "../images/gerenyaoqinghaoyou.png", wode: "邀请好友", jiantou: "../images/gerenfanhuiyou.png"
        },
      ],
      changjian:[
        {
          tu: "../images/gerenchangjianwenti.png", wode: "常见问题", jiantou: "../images/gerenfanhuiyou.png"
        },
        {
          tu: "../images/gerenyijianfankui.png", wode: "意见反馈", jiantou: "../images/gerenfanhuiyou.png"
        },
      ]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function () {
    if (app.globalData.userInfo) {
      this.setData({
        userInfo: app.globalData.userInfo,
        hasUserInfo: true
      })
    } else if (this.data.canIUse) {
      // 由于 getUserInfo 是网络请求，可能会在 Page.onLoad 之后才返回
      // 所以此处加入 callback 以防止这种情况
      app.userInfoReadyCallback = res => {
        this.setData({
          userInfo: res.userInfo,
          hasUserInfo: true
        })
      }
    } else {
      // 在没有 open-type=getUserInfo 版本的兼容处理
      wx.getUserInfo({
        success: res => {
          app.globalData.userInfo = res.userInfo
          this.setData({
            userInfo: res.userInfo,
            hasUserInfo: true
          })
        }
      })
    }
  },
  getUserInfo: function (e) {
    console.log(e)
    app.globalData.userInfo = e.detail.userInfo
    this.setData({
      userInfo: e.detail.userInfo,
      hasUserInfo: true
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})